package com.zhentao;

import com.zhentao.config.MyRuleConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Date 2024/3/26 9:46
 * @Author xdm
 **/
@EnableFeignClients("com.zhentao.apis")
@EnableDiscoveryClient
@SpringBootApplication
//当咱们去调用producer服务的时候，使用的策略是自定义的
@RibbonClient(name ="producer" ,configuration ={MyRuleConfig.class} )
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class,args);
    }



    @LoadBalanced  //添加上这个注解之后，如果使用了restTemplate，会进行拦截器里面
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
